#ifndef __TEMP_MATRIX__
#define __TEMP_MATRIX__

#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <vector>
#include <string>

//#pragma comment(lib, "opencv_core249d.lib")  
//#pragma comment(lib, "opencv_highgui249d.lib")  
//#pragma comment(lib, "opencv_imgproc249d.lib")

using namespace std;
using namespace cv;


class TempMatrixReader{
public:
	enum{
		EXIFTOOL_GETTAGS,
		EXIFTOOL_GETRAWDATA
	};

	struct FLIRParams{
		float PlanckR1,
			  PlanckR2,
			  PlanckO,
			  PlanckF,
			  PlanckB,
			  Emissivity,
              ReflectedApparentTemperature;
		string RawThermalImageType;
	};

	TempMatrixReader();

	/*	@brief run exiftool.exe
		@param exitToolPath Path of exiftool.exe
		@param jpgFileName Input jpg file name
		@param outputFileName Output txt file name
		@param processModel Model of processing, EXIFTOOL_GETTAGS for getting tag names and values, EXIFTOOL_GETRAWDATA for
		getting raw data

	*/
	void runExifTool(const string& exifToolPath, const string& jpgFileName, const string& outputFileName, int processModel);

	/*	@brief parse tags from txt file
		@param txtFileName txt file names, including the path of it.
		@param TagNames Names of tags need to be parsed
		@param isFind A vector indicates whether each tag is successfully parsed
		@params params The parsed parameters
	*/
	bool parseTags(const string& txtFileName, const vector<string>& TagNames, vector<bool>& isFind, FLIRParams& params);

	/*	@brief convert large endian to little endian, for png raw data
		@param data The input and output data
	*/
	void cvt2LittleEndian(Mat& data);

	/*	@brief compute temperature matrix from raw data
		@param rawData raw data
		@param params parameters that are used to compute temperature matrix
		@param TempMatrix the output temperature matrix
	*/
	void computeTempMatrix(const Mat& rawData, const FLIRParams& params, Mat& TempMatrix);

	/*	@breif The API that run the overall procedure of temperature matrix parsing, you can just run this single function
				to get temperature matrix.
		@param jpgFileName The input jpg file name
		@param exitToolPath The path of exiftool.exe
		@param TempMatrix The output temperature matrix
	*/
	bool getTempMatrixSingle(const string& jpgFileName, const string& exifToolPath, Mat& TempMatrix);

	vector<string> TagNames;
};


#endif